<template>
    <el-container class="layout-container-demo" style="height: 500px">
        <el-header>
            <el-space wrap :size="'large'">
                <div class="logo-title">
                    <span>
                        <a href="https://vitejs.dev" target="_blank">
                            <img src="/vite.svg" alt="Vite Logo" />
                        </a>
                    </span>
                    <span style="color: green; font-size: 20px;"> 开源软件收集平台</span>
                </div>
                <div class="search-input">
                    <el-input v-model="searchInput" placeholder="请输入搜索内容" size="large" :suffix-icon="Search" />
                </div>

                <div class="toolbar" style="text-align: right; font-size: 12px">
                    <el-dropdown>
                        <el-icon style="margin-right: 8px; margin-top: 1px">
                            <User />
                        </el-icon>
                        <template #dropdown>
                            <el-dropdown-menu>
                                <el-dropdown-item>详情</el-dropdown-item>
                                <el-dropdown-item>权限</el-dropdown-item>
                                <el-dropdown-item>标签</el-dropdown-item>
                            </el-dropdown-menu>
                        </template>
                    </el-dropdown>
                    <span>用户名</span>
                </div>

                <div class="toolbar" style="text-align: right; font-size: 12px">

                    <el-dropdown>
                        <el-icon style="margin-right: 8px; margin-top: 1px">
                            <setting />
                        </el-icon>
                        <template #dropdown>
                            <el-dropdown-menu>
                                <el-dropdown-item>详情</el-dropdown-item>
                                <el-dropdown-item>修改配置</el-dropdown-item>
                                <el-dropdown-item>
                                    <el-link type="danger">退出登陆</el-link>
                                </el-dropdown-item>
                            </el-dropdown-menu>
                        </template>
                    </el-dropdown>
                    <span>设置</span>
                </div>
            </el-space>


        </el-header>

        <el-container>
            <!-- :style="{ background: '#fff' }" -->
            <el-aside width="200px">
                <el-scrollbar :style="{ background: '#fff' }">
                    <el-menu :default-openeds="['1', '3']">
                        <el-sub-menu index="1">
                            <template #title>
                                <el-icon>
                                    <message />
                                </el-icon>软件收集
                            </template>
                            <el-menu-item-group>
                                <template #title>软件</template>
                                <el-menu-item 
                                    index="1-1"
                                    @click="changeMenu('/SoftList')"
                                >
                                    <!-- 会有<a>标签的下划线和颜色！！ -->
                                    <!-- <router-link to="/SoftList">软件列表</router-link> -->
                                    软件列表
                                </el-menu-item>
                                <el-menu-item 
                                    index="1-2"
                                    @click="changeMenu('/SoftDetail')"
                                >
                                    <!-- <router-link to="/SoftDetail">软件详情</router-link> -->
                                    软件详情
                                </el-menu-item>
                            </el-menu-item-group>
                            <el-menu-item-group title="组件">
                                <el-menu-item index="1-3" 
                                    @click="changeMenu('/ComponentList')">
                                    组件列表
                                </el-menu-item>
                            </el-menu-item-group>
                            <el-sub-menu index="1-4">
                                <template #title>组件详情</template>
                                <el-menu-item index="1-4-1"
                                    @click="changeMenu('/ComponentDetail')"
                                >
                                    详情展示
                                </el-menu-item>
                            </el-sub-menu>
                            <el-menu-item-group>
                                <template #title>依赖</template>
                                <el-menu-item index="1-5"
                                    @click="changeMenu('/DependencyList')"
                                >
                                    依赖列表
                                </el-menu-item>
                                <el-menu-item 
                                    index="1-6"
                                    @click="changeMenu('/DependencyDetail')"
                                >
                                    依赖详情
                                </el-menu-item>
                            </el-menu-item-group>
                        </el-sub-menu>

                        <el-sub-menu index="2">
                            <template #title>
                                <el-icon><icon-menu /></el-icon>Navigator Two
                            </template>
                            <el-menu-item-group>
                                <template #title>Group 1</template>
                                <el-menu-item index="2-1">Option 1</el-menu-item>
                                <el-menu-item index="2-2">Option 2</el-menu-item>
                            </el-menu-item-group>
                            <el-menu-item-group title="Group 2">
                                <el-menu-item index="2-3">Option 3</el-menu-item>
                            </el-menu-item-group>
                            <el-sub-menu index="2-4">
                                <template #title>Option 4</template>
                                <el-menu-item index="2-4-1">Option 4-1</el-menu-item>
                            </el-sub-menu>
                        </el-sub-menu>
                        <el-sub-menu index="3">
                            <template #title>
                                <el-icon>
                                    <setting />
                                </el-icon>Navigator Three
                            </template>
                            <el-menu-item-group>
                                <template #title>Group 1</template>
                                <el-menu-item index="3-1">Option 1</el-menu-item>
                                <el-menu-item index="3-2">Option 2</el-menu-item>
                            </el-menu-item-group>
                            <el-menu-item-group title="Group 2">
                                <el-menu-item index="3-3">Option 3</el-menu-item>
                            </el-menu-item-group>
                            <el-sub-menu index="3-4">
                                <template #title>Option 4</template>
                                <el-menu-item index="3-4-1">Option 4-1</el-menu-item>
                            </el-sub-menu>
                        </el-sub-menu>
                    </el-menu>
                </el-scrollbar>
            </el-aside>
            <el-container>
                <el-main :style="{ background: '#fff', padding: '24px', margin: 0, minHeight: '280px' }">
                    <el-scrollbar>
                        <!-- , textAlign: 'center' -->
                        <div :style="{ padding: '24px', background: '#fff' }">
                            <router-view></router-view>
                        </div>
                    </el-scrollbar>
                </el-main>
                <el-footer :style="{ textAlign: 'center' }">
                    文治集团 ©2018 版权所有
                </el-footer>
            </el-container>
        </el-container>
    </el-container>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
import { Menu as IconMenu, Message, Setting, User } from '@element-plus/icons-vue'
import { Search } from '@element-plus/icons-vue'
import { useRouter } from 'vue-router';

const router = useRouter();

const searchInput = ref('')

const changeMenu = (route: string) => {
    console.log("改变的侧边路由", route)
    //获取路由对象并切换
    // router.push(route)
    // Vue 重复点击相同路由报错的问题 // 目前没这个问题，不需要修改
    // 判断当前路由是否是点击的路由
    if (router.currentRoute.value.path !== route) {
        router.push(route)
    }

}

</script>

<style scoped>
.logo-title {
    flex: left;
    width: 200px;
    height: 60px;
}

.search-input {
    flex: left;
    width: 200px;
}

.layout-container-demo .el-header {
    position: relative;
    background-color: var(--el-color-primary-light-7);
    color: var(--el-text-color-primary);
}

.layout-container-demo .el-aside {
    color: var(--el-text-color-primary);
    background: var(--el-color-primary-light-8);
}

.layout-container-demo .el-menu {
    border-right: none;
}

.layout-container-demo .el-main {
    padding: 0;
}

.layout-container-demo .toolbar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    right: 20px;
}


</style>

<!-- .logo-title {
    flex: left;
    width: 200px;
    height: 60px; // 为啥这个是控制输入框高度的了？？
}

.search-input {
    flex: left;
    width: 200px;
    height: 10px; // 控制输入框高度 不管用？？
}

// 是去掉<router-link>的下划线了，但是颜色还是没去掉？？
/*设置点击前的样式 */
a {
    text-decoration: none;
}

/*设置点击后的样式 */
.router-link-active {
    text-decoration: none;
}
 -->